package cn.boysoft.module.security.manager.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.boysoft.core.log.OperateLogEntity;
import cn.boysoft.core.log.OperateLogManager;
import cn.boysoft.core.model.MessageTypeEnum;
import cn.boysoft.core.util.JsonUtil;
/**
 * @author 付厚俊
 * CreateTime 2013-4-4 下午5:22:47
 */
@Service(value="operateLogManager")
@Transactional(propagation=Propagation.REQUIRES_NEW)
public class OperateLogManagerImpl implements OperateLogManager {
	
	private final static Logger LOGGER = LoggerFactory.getLogger(OperateLogManagerImpl.class);
	@Override
	public void recordOperateLog(OperateLogEntity operateLogEntity) {
		if(operateLogEntity.getMessageType() == MessageTypeEnum.JSON){
			LOGGER.info(JsonUtil.formatJson(operateLogEntity.toJson()));
		}else{
			LOGGER.info(operateLogEntity.toXml());
		}	
	}
}
